Option Strict Off
Option Explicit On
Friend Class lista
	Inherits System.Windows.Forms.Form
	Private Const IMAGE_HEIGHT As Integer = 44 '64
	'UPGRADE_WARNING: Form event lista.Activate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
	Private Sub lista_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
		'Activar
		nombreform = Me.Name
	End Sub
	Private Sub lista_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		' detiene el msflexgrid
		DetenerScroll(listas)
	End Sub
	Private Sub lista_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim aux As String
		Dim i, cont As Integer
		Dim j, k As Integer
		Dim reg As ADODB.Recordset
		reg = New ADODB.Recordset
		Dim sql As String 'Consulta
		
		'MOSTRAR PASSWORD
		' If cadParametros <> "" Then band = 1: Call cmd_edit_Click
		
		Call conexion()
		
		'si la lista es usuario =1
		Select Case band
			Case Is = 1 'USUARIO
				'UPGRADE_WARNING: Couldn't resolve default property of object lista.Caption. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lista.Caption = "USUARIO"
				
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCont(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				cont = CShort(devolverCont("count(login)", " administrador", 0))
				listas.Rows = cont + 1
				listas.Cols = 6 '5
				With listas
					.set_TextMatrix(0, 0, "Nro.")
					.set_TextMatrix(0, 1, UCase("usuario"))
					.set_TextMatrix(0, 2, UCase("nombre"))
					.set_TextMatrix(0, 3, UCase("apellido"))
					.set_TextMatrix(0, 4, UCase("eliminar"))
					
					.set_RowHeight(0, 300)
					.set_ColWidth(0, 400)
					.set_ColWidth(1, 1600)
					.set_ColWidth(2, 1600)
					.set_ColWidth(3, 2000)
					' -- Ancho de la imagen ( 60 pixeles + 2 para el margen )
					.RowHeightMin = (IMAGE_HEIGHT * VB6.TwipsPerPixelX) + (VB6.TwipsPerPixelX * 2)
					
					i = 1
					sql = "SELECT DISTINCT login,nombres,apellidos,cod_adm" & " FROM  administrador"
					Call reg.Open(sql, conn)
					'SI EXISTE EL REGISTRO Y MUESTRA INGRESADOS DESDE EL COMBO
					If (reg.EOF = True) Then 'NO existe
						reg.Close()
					Else
						While reg.EOF = False
							If i <= .Rows - 1 Then
								.set_TextMatrix(i, 1, reg.Fields("login").Value)
								.set_TextMatrix(i, 2, reg.Fields("nombres").Value)
								.set_TextMatrix(i, 3, reg.Fields("apellidos").Value)
								.set_TextMatrix(i, 5, reg.Fields("cod_adm").Value)
								
								If i <> 1 Then
									.col = 4 : .Row = i
									' -- Leer la imagen desde el disco y Establecerla en la celda
									.CellPicture = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\dibu\user_delete_48.gif") ' & rs(sImageField) & ".jpg")
									.set_TextMatrix(i, 4, "") 'UCase("eliminar")
								End If
								
								i = i + 1
							End If
							reg.MoveNext()
						End While
						reg.Close()
					End If
					
				End With
				'ocultar columna
				listas.set_ColWidth(5, 0)
				'listas.ColIsVisible (3)
				
			Case Is = 2 'TIPO DE CAMBIO
				'UPGRADE_WARNING: Couldn't resolve default property of object lista.Caption. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lista.Caption = "TIPO DE CAMBIO"
				
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCont(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				cont = CShort(devolverCont("count(referencia)", " tipo_cambio", 0))
				i = 1
				With listas
					.Rows = cont + 1
					.Cols = 5
					
					.set_TextMatrix(0, 0, "Nro.")
					.set_TextMatrix(0, 1, UCase("referencia"))
					.set_TextMatrix(0, 2, UCase("fecha"))
					.set_TextMatrix(0, 3, UCase("moneda ") & "$us.")
					.set_TextMatrix(0, 4, UCase("eliminar"))
					.set_RowHeight(0, 300)
					.set_ColWidth(0, 400)
					.set_ColWidth(1, 2700)
					.set_ColWidth(2, 1200)
					.set_ColWidth(3, 1450)
					sql = "SELECT DISTINCT referencia,fecha,tipo_us" & " FROM  tipo_cambio"
					Call reg.Open(sql, conn)
					'SI EXISTE EL REGISTRO Y MUESTRA INGRESADOS DESDE EL COMBO
					If (reg.EOF = True) Then 'NO existe
						reg.Close()
					Else
						While reg.EOF = False
							If i <= .Rows - 1 Then
								.set_TextMatrix(i, 1, reg.Fields("referencia").Value)
								.set_TextMatrix(i, 2, reg.Fields("fecha").Value)
								.set_TextMatrix(i, 3, reg.Fields("tipo_us").Value)
								.col = 4 : .Row = i
								' -- Leer la imagen desde el disco y Establecerla en la celda
								.CellPicture = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\dibu\eliminar.jpg") ' & rs(sImageField) & ".jpg")
								.set_TextMatrix(i, 4, "") 'UCase("eliminar")
								.CellPictureAlignment = 4 'CENTRAR LA IMAGEN
								i = i + 1
							End If
							reg.MoveNext()
						End While
						reg.Close()
					End If
					.WordWrap = True
					
				End With
				
		End Select
		With listas
			For i = 1 To .Rows - 1
				.set_TextMatrix(i, 0, i & ".-")
				'.ColWidth(i) = 1500 '2000
				.set_ColAlignment(0, 2)
			Next i
		End With
		'iniciar el scroll msflexgrid
		IniciarScroll(listas)
	End Sub
	Private Sub cmd_add_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmd_add.Click
		If band = 1 Then
			With usuarios
				bandModi = 1 'nuevo
				.ShowDialog()
			End With
		ElseIf band = 2 Then 
			With tipo_Cambio
				.ShowDialog()
			End With
		End If
	End Sub
	Private Sub cmd_edit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmd_edit.Click
		Dim aux As String
		Dim aux1 As Short
		Dim explode() As String
		
		'If cadParametros = "" Then aux = listas.TextMatrix(listas.Row, 1)
		aux = listas.get_TextMatrix(listas.Row, 1)
		'aux1 = CInt(devolverCod(" nivel as cod", "administrador", "login='" & aux & "'", 0))
		
		If band = 1 Then
			
			If listas.Row <> 1 Then 'no edita el admin
				
				bandModi = 2 'editar
				With usuarios
					'Select Case cadParametros
					'Case Is = ""
					
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(1, 1, devolverCod(" cargo as cod", "administrador", "login='" & aux & "'", 0))
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(2, 1, devolverCod(" login as cod", "administrador", "login='" & aux & "'", 0))
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(3, 1, Trim(devolverCod(" contrasena as cod", "administrador", "login='" & aux & "'", 0)))
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(4, 1, devolverCod(" nombres as cod", "administrador", "login='" & aux & "'", 0))
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(5, 1, devolverCod(" apellidos as cod", "administrador", "login='" & aux & "'", 0))
					.txt_pass.Text = listas.get_TextMatrix(listas.Row, 5)
					.lbl_pass.Text = .flex_analisis.get_TextMatrix(3, 1) 'copiar el password
					'UPGRADE_WARNING: Couldn't resolve default property of object msflexpass(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.flex_analisis.set_TextMatrix(3, 1, msflexpass(.lbl_pass.Text)) 'muestrro la cantidad elementos que tiene
					'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					aux1 = CShort(devolverCod(" nivel as cod", "administrador", "login='" & aux & "'", 0))
					If aux1 = 1 Then
						.cmb_nivel.SelectedIndex = 0
						
					ElseIf aux1 = 2 Then 
						.cmb_nivel.SelectedIndex = 1
					End If
					'Case Is <> ""
					'Call colocarpass(cadParametros)
					'End Select
					.ShowDialog()
				End With
				'If cadParametros = "" Then
				Me.Close()
				'UPGRADE_WARNING: Couldn't resolve default property of object lista.Show. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lista.Show()
				'End If
			End If 'fin el admin
			
		ElseIf band = 2 Then 
			aux = listas.get_TextMatrix(listas.Row, 2) 'fecha
			If aux <> "" Then
				explode = Split(aux, "/")
				aux = explode(2) & "-" & explode(1) & "-" & explode(0)
			End If
			
			With tipo_Cambio
				.cmd_guardar.Text = "EDITAR"
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.txt_referencia.Text = devolverCod(" referencia as cod", "tipo_cambio", "fecha='" & aux & "'", 0)
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.txt_cambio.Text = devolverCod(" tipo_us as cod", "tipo_cambio", "fecha='" & aux & "'", 0)
				.dtp_tipoCambio._Value = explode(0) & "/" & explode(1) & "/" & explode(2)
				aux = explode(2) & "/" & explode(1) & "/" & explode(0)
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.lblID.Text = devolverCod(" cod_tipoCambio as cod", "tipo_cambio", "referencia='" & listas.get_TextMatrix(listas.Row, 1) & "' and fecha='" & aux & "'", 0)
				
				.ShowDialog()
				
			End With
			
		End If
		
	End Sub
	
	
	Private Sub listas_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles listas.ClickEvent
		Dim aux, aux1 As String
		
		aux1 = CStr(listas.col)
		If listas.col <> 4 Then
			Call cmd_edit_Click(cmd_edit, New System.EventArgs())
		Else
			If band = 1 Then
				If listas.Row <> 1 Then Call borrar()
			Else
				Call borrar()
			End If
		End If
	End Sub
	Sub borrar()
		Dim aux, aux1 As String
		Dim sql As String
		Dim explode() As String
		
		Select Case band
			
			Case Is = 1
				aux = listas.get_TextMatrix(listas.Row, 1)
				sql = "DELETE FROM administrador1" & " WHERE login='" & aux & "'"
				aux1 = CStr(MsgBox("Esta seguro de borrar usuario", MsgBoxStyle.OKCancel, "Borrar"))
				'If aux1 = "" Or aux1 = 2 Then aux1 = 0
			Case Is = 2
				
				explode = Split(listas.get_TextMatrix(listas.Row, 2), "/") : aux = explode(2) & "/" & explode(1) & "/" & explode(0)
				'UPGRADE_WARNING: Couldn't resolve default property of object devolverCod(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				aux1 = devolverCod(" cod_tipoCambio as cod", "tipo_cambio", "referencia='" & listas.get_TextMatrix(listas.Row, 1) & "' and fecha='" & aux & "'", 0)
				
				sql = "DELETE FROM tipo_cambio" & " WHERE cod_tipoCambio=" & aux1 & " and fecha='" & aux & "'"
				aux1 = CStr(MsgBox("Esta seguro de borrar tipo cambio", MsgBoxStyle.OKCancel, "Borrar"))
				'If aux1 = "" Or aux1 = 2 Then aux1 = 0
		End Select
		If aux1 = "" Or CDbl(aux1) = 2 Then aux1 = CStr(0)
		
		If CShort(aux1) = 1 Then
			Call finsert_Ado(sql, conn)
			Me.Close()
			'UPGRADE_WARNING: Couldn't resolve default property of object lista.Show. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			lista.Show()
		End If
		
	End Sub
End Class